package com.axc.gallery2.edit.overLay;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Display;
import android.view.Window;
import android.widget.RelativeLayout;

import com.axc.gallery2.R;
import com.axc.gallery2.edit.EditActivity;
import com.axc.gallery2.edit.ToReleaseBitmap;

public class OverLayActivity extends Activity implements IControlActivity {

	static int imageID = R.drawable.girl;
	RelativeLayout overLayout;

	OverLayView view;

	static Bitmap bmp;

	public static OverLayActivity over;

	// 主题应用
	public static OverLayActivity Talbum;
	public int theme = -1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// 主题
		Talbum = this;
		theme = getSharedPreferences("cons", MODE_PRIVATE).getInt("theme",
				android.R.style.Theme);
		setTheme(theme);
		// TODO Auto-generated method stub
		// 设置不显示标题栏
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		over = this;
		/* 
		 * * BitmapFactory.Options bmpFactoryOptions = new
		 * BitmapFactory.Options(); // 不返回实际的bitmap内存分配空间，之包含解码边界信息：图片大小
		 * bmpFactoryOptions.inJustDecodeBounds = true; // 此时返回的bmp为空 Bitmap bmp
		 * = BitmapFactory.decodeFile("/sdcard/download/Gg.jpg",
		 * bmpFactoryOptions); // 获取实际图片 bmpFactoryOptions.inJustDecodeBounds =
		 * false; bmp = BitmapFactory.decodeFile("/sdcard/download/Gg.jpg",
		 * bmpFactoryOptions);
		 */

		/**
		 * 获取图片
		 */
		bmp = new ToReleaseBitmap().RelBmp(EditActivity.imageFileNames);// BitmapFactory.decodeFile(EditActivity.imageFileNames);
		/*
		 * bmp = ((BitmapDrawable) getResources().getDrawable(imageID))
		 * .getBitmap();
		 */
		Display display = getWindowManager().getDefaultDisplay();

		if (bmp.getWidth() < bmp.getHeight()) {
			// 宽度小于高度
			overLayout = new EditOverLay(this, display.getWidth(), display
					.getHeight() - 60);
		} else if (bmp.getWidth() > bmp.getHeight()) {
			// 宽度大于高度
			overLayout = new EditOverLay(this, display.getWidth(), display
					.getHeight() - 240);
		} else {
			overLayout = new EditOverLay(this, display.getWidth(), display
					.getWidth());
		}
		setContentView(overLayout);
	}

	@Override
	public void BacktopreActivity() {
		// TODO Auto-generated method stub
		this.finish();
	}
}
